package com.qzy.demo.mapper;

import com.qzy.demo.pojo.OrderPojo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrderMapper {
    @Insert("INSERT INTO orders(orderNo,orderName,amount,addTime) "
            + "VALUES(#{orderNo}, #{orderName}, #{amount},#{addTime})")
    void addOrder(OrderPojo order);

    @Delete("DELETE FROM orders WHERE orderNo=#{orderNo}")
    void delOrder(String orderNo);

    @Update("UPDATE orders SET orderName=#{orderName} WHERE id=#{id}")
    void updOrder(OrderPojo order);

    @Select("SELECT * FROM orders")
    @Results({
            @Result(property = "orderNo",  column = "orderNo"),
            @Result(property = "orderName", column = "orderName"),
            @Result(property = "addTime", column = "addTime"),
    })
    List<OrderPojo> queryOrders();

    @Select("SELECT * FROM orders WHERE orderNo=#{orderNo}")
    @Results({
            @Result(property = "orderNo",  column = "orderNo"),
            @Result(property = "orderName", column = "orderName"),
            @Result(property = "addTime", column = "addTime"),
    })
    OrderPojo queryOrderByNo(String orderNo);
}
